#!/bin/bash
mkdir -p ~/.config/ytprofiles/
touch ~/.config/ytprofiles/config
setup() {
	read -p "Did you already setuped profiles for mpv?(Yes/No): " profile
	if [[ $profile == "Yes" ]]
	then
		ready=1
	elif [[ $profile == "yes" ]]
	then
		ready=1
	elif [[ $profile == "Y" ]]
	then
		ready=1
	elif [[ $profile == "YES" ]]
	then
		ready=1
	else
		echo Then setup them, here is link https://notabug.org/phloryglow/resYTfromCLI/src/master/Profiles.conf
	fi
	if [[ $ready == "1" ]]
	then
		echo "Fine, this script will never ask you again" && echo "profile=ok" >> ~/.config/ytprofiles/config	
	fi
}

if [[ $(grep 'profile' ~/.config/ytprofiles/config ) == "profile=ok" ]]
then
	echo 1 >> /dev/null
else
	echo "Created some files"
	setup
fi


if [[ $1  == "360" ]]
then
	mpv --profile="360p"  $2
elif [[ $1  == "480" ]]
then
	mpv --profile="480p"  $2
elif [[ $1  == "720" ]]
then
	mpv --profile="720p"  $2
elif [[ $1  == "1080" ]]
then
	mpv --profile="1080p"  $2
elif [[ $1  == "360p" ]]
then
	mpv --profile="360p"  $2
elif [[ $1  == "480p" ]]
then
	mpv --profile="480p"  $2
elif [[ $1  == "720p" ]]
then
	mpv --profile="720p"  $2
elif [[ $1  == "1080p" ]]
then
	mpv --profile="720p"  $2
else
	echo Something wrong
fi


